import React from 'react'
import { UPLOAD_URL } from './AppConfig'
import { getTimeDistance } from './util'
export const GoodsItem = (props) => {
    return (
        <div>
            <img src={ UPLOAD_URL + props.pics[0] + '.jpg' } className="goodsImage"/>
            <div>{props.title}</div>
            <div>￥{props.price}</div>
        </div>
        );
} 
export const PostItem = (props) => {
    let gpsInfo = '';
    if (props.gps != '') {
        gpsInfo = <div> {props.gpscity}{props.gpsaddr}</div>;
    }
    let timeDistance = getTimeDistance(props.createdate)
    return (
        <div>
            <div className="postAuthor">
                <img src={props.authorInfo.headimg} className="postAuthorImage"/>
                <div className="postAuthorNickName">{props.authorInfo.nickname}</div>
            </div>
            <div>{props.text}</div>
            {gpsInfo}
            <div className="postFooter">
                <div className="FooterLeftContent">发布于{timeDistance}</div>
                <div className="FooterRightContent">
                    <div>
                        <div className="iconfont icon-browse">{props.viewcount}</div>
                    </div>
                    <div>
                        <div className="iconfont icon-message">{props.commentcount}</div>
                    </div>
                </div>
            </div>
        </div>
        );
}